

#ifndef UCDB_DBGROUP_H
#define UCDB_DBGROUP_H

#include "zdbmain.h"
#include "zdbapserv.h"

#pragma pack(push, 8)

class UcDbGroupIterator;

class UcDbGroup: public  UcDbObject
{
public:
    UCDB_DECLARE_MEMBERS(UcDbGroup);
    UcDbGroup();
    UcDbGroup(const ZTCHAR * grpDesc, bool selectable = true);
    virtual ~UcDbGroup();

    UcDbGroupIterator*  newIterator();

    const ZTCHAR *       description() const;
    Ucad::ErrorStatus   setDescription(const ZTCHAR * grpDesc);

    bool                isSelectable() const;
    Ucad::ErrorStatus   setSelectable(bool selectable);

    const ZTCHAR *       name() const;
    Ucad::ErrorStatus   getName(ZTCHAR *& name) const;
    Ucad::ErrorStatus   setName(const ZTCHAR * newName);

    bool                isNotAccessible() const;

    bool                isAnonymous() const;
    Ucad::ErrorStatus   setAnonymous();

    Ucad::ErrorStatus   append(UcDbObjectId id);
    Ucad::ErrorStatus   append(UcDbObjectIdArray ids);
    Ucad::ErrorStatus   prepend(UcDbObjectId id);
    Ucad::ErrorStatus   prepend(UcDbObjectIdArray ids);
    Ucad::ErrorStatus   insertAt(ZSoft::UInt32 idx, UcDbObjectId id);
    Ucad::ErrorStatus   insertAt(ZSoft::UInt32 idx, UcDbObjectIdArray ids);
    Ucad::ErrorStatus   remove(UcDbObjectId id);
    Ucad::ErrorStatus   removeAt(ZSoft::UInt32 idx);
    Ucad::ErrorStatus   remove(UcDbObjectIdArray ids);
    Ucad::ErrorStatus   removeAt(ZSoft::UInt32 idx, UcDbObjectIdArray ids);
    Ucad::ErrorStatus   replace(UcDbObjectId oldId, UcDbObjectId newId);
    Ucad::ErrorStatus   transfer(ZSoft::UInt32 fromIndex, 
                                 ZSoft::UInt32 toIndex, 
                                 ZSoft::UInt32 numItems);

    Ucad::ErrorStatus   clear();
    ZSoft::UInt32       numEntities() const;
    bool                has(const UcDbEntity* pEntity) const;
    ZSoft::UInt32       allEntityIds(UcDbObjectIdArray& ids) const;
    Ucad::ErrorStatus   getIndex(UcDbObjectId id, ZSoft::UInt32& idx) const;
    Ucad::ErrorStatus   reverse();

    Ucad::ErrorStatus   setColor(const UcCmColor& color);
    Ucad::ErrorStatus   setColorIndex(ZSoft::UInt16 color);
    Ucad::ErrorStatus   setLayer(const ZTCHAR * newVal);
    Ucad::ErrorStatus   setLayer(UcDbObjectId newVal);
    Ucad::ErrorStatus   setLinetype(const ZTCHAR * newVal);
    Ucad::ErrorStatus   setLinetype(UcDbObjectId newVal);
    Ucad::ErrorStatus   setLinetypeScale(double newval);
    Ucad::ErrorStatus   setVisibility(UcDb::Visibility newVal);
    Ucad::ErrorStatus   setHighlight(bool newVal);

    Ucad::ErrorStatus   setMaterial(const ZTCHAR * newVal);
    Ucad::ErrorStatus   setMaterial(UcDbObjectId newVal);
    virtual Ucad::ErrorStatus applyPartialUndo(UcDbDwgFiler* undoFiler,
                                               UcRxClass*    classObj);

    virtual Ucad::ErrorStatus subClose();
    virtual Ucad::ErrorStatus subErase(ZSoft::Boolean erasing = true);

    virtual void              erased(const UcDbObject* dbObj,
                                     ZSoft::Boolean erasing = true);
    virtual void              goodbye(const UcDbObject* dbObj);

    virtual Ucad::ErrorStatus dwgInFields(UcDbDwgFiler* pFiler);
    virtual Ucad::ErrorStatus dwgOutFields(UcDbDwgFiler* pFiler) const;

    virtual Ucad::ErrorStatus dxfInFields(UcDbDxfFiler* pFiler);
    virtual Ucad::ErrorStatus dxfOutFields(UcDbDxfFiler* pFiler) const;

    virtual Ucad::ErrorStatus getClassID(CLSID* pClsid) const;
};

class ZSOFT_NO_VTABLE UcDbGroupIterator: public UcRxObject
{
public:
    UCRX_DECLARE_MEMBERS(UcDbGroupIterator);
    virtual ~UcDbGroupIterator() {}

    virtual Ucad::ErrorStatus getObject(UcDbObject*& pObject,
        UcDb::OpenMode) = 0;
    virtual UcDbObjectId      objectId () const = 0;

    virtual bool              done     () const = 0;
    virtual bool              next     () = 0;

protected:
    UcDbGroupIterator() {}
};

#pragma pack(pop)

#endif
